<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="huoyun" uri="/huoyun"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>发布车源信息</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/theme/css/main.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/theme/css/style_userCenter.css">

<script type="text/javascript"
	src="${pageContext.request.contextPath}/theme/js/jquery-1.6.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/theme/js/jquery.form.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/theme/js/jquery.validate.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/theme/js/additional-methods.js"></script>
</head>

<body>		 
	<script type="text/javascript">
	$(document).ready(function(){
		var valid = $("#driver_form").validate({
				errorPlacement: function(error, element) {
					    // element.parent("td").append(error);
					     element.attr("title", error.html());
					   },
				rules : {
					"driver.name" : {
						required : true
					},
					"driver.province" : {
						required : true,
						isValid : true
					},
					"driver.city" : {
						required : true,
						isValid : true
					},
					"driver.town" : {
						required : true,
						isValid : true
					},
					"driver.mobilePhone":{
						mobile: true
					},
					"driver.idCardNumber" : {
						required : true,
						identityCard : true,
						remote : {
			  				url : "${pageContext.request.contextPath}/car/checkDriverIdCardNumber.action",
			  				type : "post"
						}
					},
					"driver.drivingLicenseCarType" : {
						required : true
					},
					"driver.drivingLicenseNumber" : {
						required : true,
						remote : {
			  				url : "${pageContext.request.contextPath}/car/checkDriverDrivingLicenseNumber.action",
			  				type : "post"
						}
					},
					"driver.drivingLicenseEffectivePeriod":{
						number:true
					}
				},
				messages : {
					"driver.name" : {
						required : "请输入姓名"
					},
					"driver.province" : {
						required : "请选择省",
						isValid : true
					},
					"driver.city" : {
						required : "请选择市",
						isValid : true
					},
					"driver.town" : {
						required : "请选择区（县）",
						isValid : true
					},
					"driver.mobilePhone":{
						mobile: "请输入正确的电话号码"
					},
					"driver.idCardNumber" : {
						required : "请填写身份证",
						identityCard : "请填写有效的身份证",
						remote : "身份证号已存在"
					},
					"driver.drivingLicenseCarType" : {
						required : "请填写准驾车型"
					},
					"driver.drivingLicenseNumber" : {
						required : "请填写驾驶证编号",
						remote : "驾驶证号已存在"
					},
					"driver.drivingLicenseEffectivePeriod":{
						number: "请以数字的形式填写有效期限"
					}
				}
			});	
			$('#driver_form').submit(function()//提交表单
	        {
	           	var options = { 
		            //target:'#Tip',
		            url:'/huoyun/car/addDriver.action',
		            type:'POST',
		            dataType:'json',
		            beforeSubmit:  function() {
		            },
		            success: function(data){
		            	/*alert("hh");
		            	if(data.driverList.length == 0){
		            		alert('length=0');
		            	}*/
		            	var drivers = data.driverList;
		            	if ($driver_select != undefined && $driver_select != null) {
			            	$driver_select.empty();
			            	$driver_select.append("<option value='-1'>请选择</option>");
			            	for (var i = 0; i < drivers.length; i++) {
								$driver_select.append("<option value='"+ drivers[i].id +"'>"+ drivers[i].name +"</option>");
		               		}
		               		$driver_select.val(data.driverId);
		               		//$("#driver_select option[value='']").attr("selected",true);
		            	}
		            	dialog.close();
		            }
	            }; 
	           	if (valid.form() == true)
	            	$('#driver_form').ajaxSubmit(options); 
	            return false;
	        });
		});
	</script>
 
 	
	
	<div id="car_driver_info_div" class="form_wrap clearfix"  style="min-width:400px; max-height:500px;">
	<div style="color: red; margin-left: 100px;">
		<s:property value="resultMsg" />
		<s:fielderror></s:fielderror>
	</div>
	<form id="driver_form">
	<table class="tableForm registerCar">
		<tbody>
			<!-- 司机个人基本信息 -->
			<tr>
				<td colspan="2" >
					<h2>司机个人基本信息</h2>
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
					<span class="required-field">*</span>姓名:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.name" id="driver.name"
					class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					性别:
				</td>
				<td class="tdValue">
					<label for="male"><input type="radio"
					name="driver.gender" id="male" value="0" />男</label> <label
					for="female"><input type="radio"
					name="driver.gender" id="female" value="1" />女</label> <span
					id="gender_error_span" class="box-error"><b
					id="gender_error_span_i"></b> </span>
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					民族:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.nation" id="driver.nation"
					class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					生日:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.birthDate"
					id="driver.birthDate" class="Wdate" onClick="WdatePicker()" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					<span class="required-field">*</span>住址:
				</td>
				<td class="tdValue">
					<!-- <input type="text" name="driver.address" id="driver.address"
					style="WIDTH:400px" class="inputtext" /> -->
					<huoyun:regionSelect provinceName="driver.province" cityName="driver.city" townName="driver.town" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					<span class="required-field">*</span>手机号码:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.mobilePhone" id="driver.mobilePhone"
					class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="100">
					<span class="required-field">*</span>身份证号码:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.idCardNumber"
					id="driver.idCardNumber" class="inputtext" />
				</td>
			</tr>
			<tr>
				<td colspan="2" >
					<h2>驾驶证信息</h2>
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
					<span class="required-field">*</span>准驾车型:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.drivingLicenseCarType"
					id="driver.drivingLicenseCarType" class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
					<span class="required-field">*</span>档案编号:
				</td>
				<td class="tdValue">
					<input type="text" name="driver.drivingLicenseNumber"
					id="driver.drivingLicenseNumber" class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
					有效起始日期:
				</td>
				<td class="tdValue">
					<input type="text"
					name="driver.drivingLicenseEffectiveStartDate"
					id="driver.drivingLicenseEffectiveStartDate" class="Wdate"
					onClick="WdatePicker()" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
					有效期限:
				</td>
				<td class="tdValue">
					<input type="text"
					name="driver.drivingLicenseEffectivePeriod"
					id="driver.drivingLicenseEffectivePeriod" class="inputtext" />
				</td>
			</tr>
			<tr>
				<td class="tdLabel" width="120">
				</td>
				<td class="tdValue">
					<input id="ee" type="submit" class="default_btn" value="添加" />
				</td>
			</tr>
		</tbody>
		</table>
	</form>
	</div>
	<!-- 司机准驾信息结束 -->
</body>
</html>
